<template>
<div>
<!-- 按钮 -->
<div class="bnts">
    <br>
    <el-form size="small" inline>
        <el-form-item >
            <el-input v-model="param.name" placeholder="请输入姓名"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button type="primary" icon="el-icon-search"  @click="loadConfigs">搜索</el-button>
            <el-button size="small" @click="toAddHandler"  type="primary"><i class="el-icon-plus"></i>添加</el-button>
        </el-form-item>
           <el-button size="small" type="primary" style="float:right" @click="loadMapHandler"><i class="el-icon-location"></i>地图</el-button>
           <el-button size="small" type="primary" style="float:right;margin-right:10px" @click="loadRecognitionHandler"><i class="el-icon-view"></i>图像识别</el-button>
    </el-form>
</div>
<!-- 表格 -->
<el-table :data="config">
    <el-table-column type="index" :index=1  label="序号" width="100"></el-table-column>
    <el-table-column prop="name"  label="姓名"></el-table-column>
    <el-table-column prop="val" label="val"></el-table-column>
    <el-table-column prop="introduce" label="介绍"></el-table-column>
    <el-table-column  label="操作" width="150" align="center">
        <template slot-scope="scope">
            <el-button type="text"  @click="deleteHandler(scope.row)"><i class="el-icon-delete"></i>删除</el-button>
            <el-button type="text"  @click="editHandler(scope.row)"><i class="el-icon-edit"></i>修改</el-button>
        </template>
    </el-table-column>
</el-table>
<br>
<el-button size="small" type="primary" style="float:right" @click="DownloadHandler">导出</el-button>

</div>
</template>

<script>
import {del, get, post} from '@/utils/request'

export default {
data (){
    return {
        param:{
            name:""
        },
        config:[]
    }
},

//方法表示一个具体的操作，主要书写业务逻辑；
 methods: { 
     DownloadHandler(){
      window.location.href = "http://39.106.31.187:8888/BaseConfig/download?name="+this.param.name
     },
     loadRecognitionHandler(){
        this.$router.push({
            path:"/config/configRecognition",//跳转到前端路由
        });
     },
     loadMapHandler(){
        this.$router.push({
            path:"/config/configMap",//跳转到前端路由
        });
     },
     //更新
     editHandler(row){
        //跳转到修改页面
        //携带当前行数据
        this.$router.push({
            path:"/config/configCreate",//跳转到前端路由
            query:row,
        });
     },
     //删除
     deleteHandler(row){
        this.$confirm("此操作将永久删除该数据, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        }).then(() => {
        let url='http://39.106.31.187:8888/BaseConfig/deleteById'
        del(url,{id:row.id}).then(resp=>{
            this.$message({type:"success",message:resp.message});
            this.loadConfigs();
         });
      });
     },
     //跳转到保存界面
     toAddHandler(){
         this.$router.push("/config/configCreate")
     },
     loadConfigs(){
         let url='http://39.106.31.187:8888/BaseConfig/query'
         get(url,this.param).then(resp=>{
             this.config=resp.data;
         })
     }
 },
//请求数据
 created() {
     this.loadConfigs();
    }
}
</script>

<style scoped>

</style>
